package xmlParsers;

import java.io.File;
import java.io.IOException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;

public class SystemParserRemito {

	
		private static SystemParserRemito instancia;
		
		private DocumentBuilderFactory factory;
		
		private SystemParserRemito() {
			this.factory = DocumentBuilderFactory.newInstance();
			factory.setIgnoringElementContentWhitespace(true);
		}

		public static SystemParserRemito getInstance() {
			if (instancia == null)
				return new SystemParserRemito();
			return instancia;
		}
		
		
		public int numeroOrdenCompra(String path) throws ParserConfigurationException, SAXException, IOException{
			String numero= "";
			DocumentBuilder builder = this.factory.newDocumentBuilder();
			File f = new File(path);
			
			if (f != null) {
				
				Document doc = builder.parse(f);
				Element root = doc.getDocumentElement();
				numero=root.getAttribute("numeroOrden");
			
		}
			
			return Integer.parseInt(numero);
			
			
		
		}

	}


